package com.home.admin.monitor;

import com.home.base.core.framework.msg.ServerResponse;
import com.home.common.annotation.CheckApiClient;
import com.home.common.annotation.Log;
import com.home.common.constants.client.ClientConstant;
import com.home.common.constants.log.LogTypeConstant;
import com.home.common.framework.core.controller.BaseController;
import com.home.webapp.monitor.entity.BaseUserOnline;
import com.home.webapp.monitor.service.BaseUserOnlineService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


/**
 * Description: 在线用户记录 controller
 * Created by 王大宸 on 2020-10-12 22:27:31
 * Created with IntelliJ IDEA.
 */
@Controller
@RequestMapping(value = "/monitor/user/online")
@CheckApiClient(title = "在线用户记录", clientId = ClientConstant.CLIENT_WEB)
public class BaseUserOnlineController extends BaseController<BaseUserOnlineService, BaseUserOnline, String> {
    private static final Logger logger = LoggerFactory.getLogger(BaseUserOnlineController.class);

    private static final String PATH_PREFIX = "monitor/online";

    /***
     * 功能描述：跳转到信息管理界面
     *
     * @author 王大宸
     * @date 2020-10-12 22:27:31
     * @param
     * @return java.lang.String
     */
    @GetMapping(value = "/index")
    @RequiresPermissions("monitor:baseUserOnline:index")
    public String index() {
        return PATH_PREFIX + "/index";
    }

    /***
     * 功能说明：强退
     *
     * @author 王大宸
     * @date 2020/10/14 23:23
     * @param id 需要强行退出的id
     * @return com.home.common.framework.msg.ServerResponse<com.home.webapp.monitor.entity.BaseUserOnline>
     */
    @DeleteMapping(value = "/force/{id}")
    @ResponseBody
    @Log(title = "强退", operateType = LogTypeConstant.FORCE_RETURN)
    public ServerResponse<BaseUserOnline> force(@PathVariable("id") String id) throws Exception {
        baseService.remove(id);
        return ServerResponse.ok();
    }

}